<!DOCTYPE html>
<html class="x-admin-sm">
{include file="common/static" /}
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>房间id
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="room_id" name="room_id" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input" value="{$id}">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>物品
                        </label>
                        <div class="layui-input-inline layui-show-xs-block">


                            <select id="goods_id">
                                {volist name="list" id="vo"}
                                <option value=" {$vo.id}">{$vo.goods_name}</option>
                                {/volist}
                            </select>

                        </div>
                    </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>物品数量
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="goods_num" name="goods_num" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" type="button" onclick="adds()">
                          增加
                      </button>
                  </div>
              </form>
            </div>
        </div>

    </body>
<script>
    layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });

    function adds(){
        $.ajax({
            type:"post",
            url: "{:url('home/lease/add_rental')}",
            data: {
                room_id:$('#room_id').val(),
                goods_id:$('#goods_id').val(),
                goods_num:$('#goods_num').val(),
            },
            success: function(data){
                console.log(data);
                toastr.error(data.msg);
                if(data.code == 100){
                    setTimeout(function () {
                        layer.closeAll();
                        parent.location.reload();
                    },1500);
                }
            }});
    }
</script>

</html>
